#ifndef SPSEGMENT_H_INCLUDED
#define SPSEGMENT_H_INCLUDED

#include "Record.h"
#include "Segment.h"

struct TID
{
    unsigned pageId;
    unsigned slotId;

    bool operator<(const TID& other) const
    {
        if(pageId == other.pageId)
            return slotId < other.slotId;
        else
            return pageId < other.pageId;
    }

    bool operator==(const TID& other) const {return (pageId == other.pageId) && (slotId == other.slotId);}
};

class SPSegment
{
public:
    SPSegment(Segment& s);

    SPSegment(const SPSegment& other) = delete;
    SPSegment operator=(const SPSegment& other) = delete;

    TID insert(const Record& r);
    bool deleteRecord(TID tid);
    Record lookup(TID tid);
    bool update(TID tid, const Record& r);
    bool update(TID tid, const Record& r, bool allowOutsourcing);
    ~SPSegment();

protected:

private:
    Segment& segment;

};

#endif // SPSEGMENT_H_INCLUDED

